/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.xtd.model.admin;

import com.xtd.model.employment.Employee;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Lu Yuanbin
 */
@Entity
@Table(name = "xtduser")
@NamedQueries({
    @NamedQuery(name = "Xtduser.findAll", query = "SELECT x FROM Xtduser x")})
public class Xtduser implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "username")
    private String username;
  
    @Column(name = "display_name")
    private String displayName;
    @Basic(optional = false)
    @Column(name = "password")
    private String password;
    @ManyToMany(mappedBy = "xtduserCollection", fetch = FetchType.EAGER)
    private List<Xtdgroup> xtdgroupList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "xtduser")
    private Collection<Employee> emloyeeCollection;
    @OneToMany(mappedBy = "xtduser", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.DELETE, org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
    private List<UserGroup> xtdroleList;

    public Xtduser() {
    }

    public Xtduser(String username) {
        this.username = username;
    }

    public Xtduser(String username, String displayName, String password) {
        this.username = username;
        this.displayName = displayName;
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Collection<Employee> getEmloyeeCollection() {
        return emloyeeCollection;
    }

    public void setEmloyeeCollection(Collection<Employee> emloyeeCollection) {
        this.emloyeeCollection = emloyeeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (username != null ? username.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Xtduser)) {
            return false;
        }
        Xtduser other = (Xtduser) object;
        if ((this.username == null && other.username != null) || (this.username != null && !this.username.equals(other.username))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.xtd.model.Xtduser[username=" + username + "]";
    }

    /**
     * @return the xtdgroupList
     */
    public List<Xtdgroup> getXtdgroupList() {
        return xtdgroupList;
    }

    /**
     * @param xtdgroupList the xtdgroupList to set
     */
    public void setXtdgroupList(List<Xtdgroup> xtdgroupList) {
        this.xtdgroupList = xtdgroupList;
    }

   

    /**
     * @return the xtdroleList
     */
    public List<UserGroup> getXtdroleList() {
        return xtdroleList;
    }

    /**
     * @param xtdroleList the xtdroleList to set
     */
    public void setXtdroleList(List<UserGroup> xtdroleList) {
        this.xtdroleList = xtdroleList;
    }
}
